package fuzion24.device.vulnerability.vulnerabilities.helper;

public abstract class TestResult {

    public boolean isOk() {
        return false;
    }

    public abstract int getCode();

    public abstract String toString();

    public static TestResult OK(int code) {
        return new Ok(code);
    }

    public static final TestResult ERROR = new TestResult() {
        @Override
        public int getCode() {
            return 255;
        }

        @Override
        public String toString() {
            return "Error";
        }
    };

    public static final TestResult CRASH = new TestResult() {
        @Override
        public int getCode() {
            return 254;
        }

        @Override
        public String toString() {
            return "Crash";
        }
    };

    public static final TestResult HANG = new TestResult() {
        @Override
        public int getCode() {
            return 253;
        }

        @Override
        public String toString() {
            return "Hang";
        }
    };

    public static class Ok extends TestResult {
        private final int code;

        public Ok(int code) {
            super();
            this.code = code;
        }

        @Override
        public boolean isOk() {
            return true;
        }

        @Override
        public int getCode() {
            return code;
        }

        @Override
        public String toString() {
            return "Ok (" + code + ")";
        }
    }
}
